import request from "../utils/request";
export default { 
    getOperateLogList(pageNum,oageSize){
        const params = {
            pageNum: pageNum,
            pageSize: oageSize
        }
        return request.get("/operate",{params},
            {method:"get"}
        )
    },
    getSpecieOperation(userName,ipAddress,operateType,time,pageNum,pageSize){
        const params={
            userName,
            ipAddress,
            operateType,
            // 安全访问 time 数组，未选择时间时自动过滤字段
            ...(time?.[0] && { startTime: time[0] }),  // 仅当 time[0] 存在时添加 startTime
            ...(time?.[1] && { endTime: time[1] }),     // 仅当 time[1] 存在时添加 endTime
            pageNum,
            pageSize
        }
        console.log(params);
        
        
        return request.get("/operate/getSpecieOperation",{params},{
            method:"get"
        })
    },
    deleteOperation(id) {
        let params;
        if (typeof id === "string") {
            params = {
                id: [id]
            }
            console.log("ssss")
            return request.delete("/operate/"+id, {}, {
                method: "delete"
            })
        } else {
            params = {
                id
            }
            const idsString = Array.isArray(id) ? id.join(',') : id.toString();
            console.log("xxxxx")
            return request.delete("/operate/"+idsString, {}, {
                method: "delete"
            })
        }
    },
    deleteOperationAll(){
        return request.delete("/operate",{},{
            method:"delete"
        })
    }
}